<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>4-正则边界符</title>
</head>
<body>
    <script>
        //设置一个匹配abc的正则(只要在字符中包含abc的都可以)
        var reg = /abc/;
        //借助test方法去校验
        console.log(reg.test('abc'));//true
        console.log(reg.test('abcdefg'));//true
        console.log(reg.test('123abc'));//true
        console.log(reg.test('****abc#####'));//true
        console.log(reg.test('****ab@@@@'));//false
        console.log('----------------@1------------------');
        //边界符 ^ 表示从哪块开始匹配
        var reg2 = /^baidu/;
        console.log(reg2.test('baidu.com'));//true
        console.log(reg2.test('cn.baidu'));//false
        console.log(reg2.test('abcd'));//false
        //边界符 $ 从哪块结尾
        console.log('-------------@2-----------');
        //表示从www开始到www结尾
        var reg3 = /^www$/;

        console.log(reg3.test('www'));
        console.log(reg3.test('www.baidu.com'));
        console.log(reg3.test('www.sina.cn'));




    </script>
</body>
</html>